//
//  TYTabBarController.swift
//  Weibo
//
//  Created by 李田 on 16/12/2.
//  Copyright © 2016年 tianyao. All rights reserved.
//

import UIKit

class TYTabBarController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        addChildViewController(childController: TYHomeController(), imageName: "tabbar_home", title: "首页")
        addChildViewController(childController: TYMessageController (), imageName: "tabbar_discover", title: "消息")
        addChildViewController(childController: TYDiscoverController(), imageName: "tabbar_message_center", title: "发现")
        addChildViewController(childController: TYProfileController(), imageName: "tabbar_profile", title: "我的")
    }
    
        // MARK: 重载添加子视图控制器
     func addChildViewController(childController: UIViewController, imageName: String, title: String) {
        
        // 设置tabBar图片
        childController.tabBarItem.image = UIImage(named: imageName)
        childController.tabBarItem.selectedImage = UIImage(named: imageName + "_selected")?.withRenderingMode(.alwaysOriginal)
        // 设置tabBar的文字及字体
        childController.title = title
        
        childController.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orange], for: .selected)
        childController.tabBarItem.setTitleTextAttributes([NSFontAttributeName: UIFont.systemFont(ofSize: 12)], for: .normal)
        
        addChildViewController(childController)
    }

}
